
require 'libglade2'

ADDDIALOG_FILE = "adddialog.glade"
ADDDIALOG_TITLE = "Add links"

class AddDialog
  attr :glade
  attr :dialog
  attr_accessor :text
  
  attr :widget
  
  def initialize caller
    @caller = caller
    @glade = GladeXML.new(ADDDIALOG_FILE, nil, ADDDIALOG_TITLE, nil, GladeXML::FILE) { |handler| method(handler)}
    @dialog = @glade['adddialog']
    @dialog.show_all
  end
  
  def on_adddialog_addbutton_clicked
    text = @glade['textview'].buffer.text
    @dialog.destroy
    @caller.add_links_from_text(text)
  end
  
  def on_adddialog_cancelbutton_clicked
    @dialog.destroy
  end
  
end